package de.roon.weighttracker;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

public class Overview extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_overview);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.menu_overview, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// React on Options Menu clicked
		switch (item.getItemId()) {
		case R.id.menu_ov_add:
			onOptAdd();
            return true;
		case R.id.menu_ov_all:
			onOptAll();
			return true;
		case R.id.menu_ov_help:
			onOptHelp();
			return true;
		case R.id.menu_ov_settings:
			onOptSettings();
			return true;
        default:
        	return super.onOptionsItemSelected(item);
		}
	}
	
	// Called when Option "Add" is clicked
	public void onOptAdd() {
		Intent intent = new Intent(this, AddWeight.class);
        startActivityForResult(intent, 1);
	}
	
	// Called when Option "All Entries" is clicked
	public void onOptAll() {
		Context context = getApplicationContext();
		CharSequence text = "Tbc..";
		int duration = Toast.LENGTH_SHORT;

		Toast toast = Toast.makeText(context, text, duration);
		toast.show();
	}
	
	// Called when Option "Help" is clicked
	public void onOptHelp() {
		Context context = getApplicationContext();
		CharSequence text = "<3 I love you Kuschemuschel! <3";
		int duration = Toast.LENGTH_SHORT;

		Toast toast = Toast.makeText(context, text, duration);
		toast.show();
	}
	
	// Called when Option "Settings" is clicked
	public void onOptSettings() {
		Intent intent = new Intent(this, SettingsActivity.class);
        startActivityForResult(intent, 1);
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		
		super.onActivityResult(requestCode, resultCode, data);
	}
	
	
}
